home *** CD-ROM | disk | FTP | other *** search
/ Complete Linux / Complete Linux.iso / docs / apps / database / ingres04.lzh / source / iutil / inpcloser.c < prev    next >
Encoding:
C/C++ Source or Header  |  1985-01-23  |  814 b   |  46 lines

  1. # include    <ingres.h>
  2. # include    <access.h>
  3. # include    <sccs.h>
  4.  
  5. SCCSID(@(#)inpcloser.c    8.1    12/31/84)
  6.  
  7. /*
  8. **    inpcloser - close an input relation
  9. **
  10. **    The relation must have been opened by openr with 
  11. **        mode 0 (read only)
  12. **
  13. **    return values:
  14. **        <0 fatal error
  15. **         0 success
  16. **         1 relation was not open
  17. **         2 relation was opened in write mode
  18. **
  19. **    Trace Flags:
  20. **        21.10-11
  21. */
  22.  
  23. inpcloser(d)
  24. register DESC    *d;
  25. {
  26.     register int    i;
  27.  
  28. #    ifdef xATR1
  29.     if (tTf(21, 10))
  30.         printf("inpcloser: %.14s\n", d->reldum.relid);
  31. #    endif
  32.     if (abs(d->relopn) != (d->relfp + 1) * 5)
  33.         /* relation not open */
  34.         return (1);
  35.  
  36.     if (d->relopn < 0)
  37.         return (2);    /* relation open in write mode */
  38.  
  39.     i = flush_rel(d, TRUE);    /* flush and reset all pages */
  40.  
  41.     if (close(d->relfp))
  42.         i = acc_err(AMCLOSE_ERR);
  43.     d->relopn = 0;
  44.     return (i);
  45. }
  46.